using System;
using System.Windows.Forms;

namespace WegasManagementSystem.Forms
{
    /// <summary>
    /// 导出进度显示窗体
    /// </summary>
    public partial class ExportProgressForm : Form
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public ExportProgressForm()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 更新进度条值
        /// </summary>
        /// <param name="value">当前进度值</param>
        public void UpdateProgress(int value)
        {
            if (InvokeRequired)
            {
                Invoke(new Action<int>(UpdateProgress), value);
                return;
            }

            progressBar.Value = value;
        }

        /// <summary>
        /// 更新状态文本
        /// </summary>
        /// <param name="text">状态文本</param>
        public void UpdateStatus(string text)
        {
            if (InvokeRequired)
            {
                Invoke(new Action<string>(UpdateStatus), text);
                return;
            }

            lblStatus.Text = text;
        }

        /// <summary>
        /// 设置状态文本
        /// </summary>
        /// <param name="text">状态文本</param>
        public void SetStatus(string text)
        {
            if (InvokeRequired)
            {
                Invoke(new Action<string>(SetStatus), text);
                return;
            }

            lblStatus.Text = text;
        }

        /// <summary>
        /// 设置进度条最大值
        /// </summary>
        /// <param name="maxValue">最大值</param>
        public void SetMaximum(int maxValue)
        {
            if (InvokeRequired)
            {
                Invoke(new Action<int>(SetMaximum), maxValue);
                return;
            }

            progressBar.Maximum = maxValue;
        }
    }
}
